package com.ruoyi.reportTask.mapper;

import com.ruoyi.reportTask.domain.IndustrialReportTaskCenter;
import com.ruoyi.reportTask.domain.vo.IndustrialReportTaskCenterVo;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

/**
 * 填报任务中心Mapper接口
 *
 * @author yangzhen
 * @date 2025-11-18
 */
public interface IndustrialReportTaskCenterMapper extends BaseMapperPlus<IndustrialReportTaskCenterMapper, IndustrialReportTaskCenter, IndustrialReportTaskCenterVo> {
    @Select("SELECT COUNT(1) FROM industrial_report_task_center " +
        "WHERE task_id = #{taskId} AND send_date = #{sendDate} AND del_flag = '0'")
    int countByTaskIdAndDeadline(@Param("taskId") String taskId, @Param("sendDate") Date sendDate);

    default boolean existsTaskForDate(String taskId, Date date) {
        return countByTaskIdAndDeadline(taskId, date) > 0;
    }
}
